<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="res/install/install.css" />
		<link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
		<script src="http://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script>
	</head>

	<body>
		<div class="container">
			<h1 class="heading-primary">欢迎使用本系统、请先完成配置</h1>
			<h5 class="" style="color: red;" id="tip"></h5>
			<div class="accordion">
				<dl>
					<dt>
	                <a href="#accordion1" aria-expanded="false" aria-controls="accordion1" class="accordion-title accordionTitle js-accordionTrigger">渠道账号配置</a>
	              </dt>
					<dd class="accordion-content accordionItem is-collapsed" id="accordion1" aria-hidden="true">
						<form name="wechat" class="form-horizontal" role="form">
							<fieldset>
								<legend>微信</legend>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="appid">AppId</label>
									<div class="col-sm-10">
										<input class="form-control" id="appid" type="text" placeholder="root" value="wx84276b4fc0fea08b" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="aeskey">EncodingAESKey</label>
									<div class="col-sm-10">
										<input class="form-control" id="aeskey" type="text" placeholder="root" value="q9T7G7IUpJJciB7lxRgJNhUk9Es5Sz52kpGLGClQdOK"/>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="appsecret">AppSecret</label>
									<div class="col-sm-10">
										<input class="form-control" id="appsecret" type="text" placeholder="root" value="d4624c36b6795d1d99dcf0547af5443d" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="token">Token</label>
									<div class="col-sm-10">
										<input class="form-control" id="token" type="text" placeholder="root" value="mchat" />
									</div>
								</div>
							</fieldset>
							<fieldset>
								<legend>邮件服务器</legend>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="appid">Service</label>
									<div class="col-sm-10">
										<input class="form-control" id="appid" type="text" placeholder="root" value="smtp.qq.com" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="aeskey">Account</label>
									<div class="col-sm-10">
										<input class="form-control" id="aeskey" type="text" placeholder="root" value="710335997@qq.com"/>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="appsecret">Password</label>
									<div class="col-sm-10">
										<input class="form-control" id="appsecret" type="text" placeholder="root" value="password" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="token">Name</label>
									<div class="col-sm-10">
										<input class="form-control" id="token" type="text" placeholder="root" value="毛毛猴客服系统" />
									</div>
								</div>
							</fieldset>
							<fieldset>
								<legend>文件服务器</legend>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="appid">Domain</label>
									<div class="col-sm-10">
										<input class="form-control" id="appid" type="text" placeholder="root" value="http://7xrn9i.com1.z0.glb.clouddn.com/" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="aeskey">ACCESS_KEY</label>
									<div class="col-sm-10">
										<input class="form-control" id="aeskey" type="text" placeholder="root" value="CxotMa3cWZC4EhtfB4wHRG-UEBvzXjtwzPMV2OCB"/>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="appsecret">SECRET_KEY</label>
									<div class="col-sm-10">
										<input class="form-control" id="appsecret" type="text" placeholder="root" value="wpTkX2hUKlSH65I-Nn8-ABrGmWjoAlTyEZOoxODC" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="token">bucket</label>
									<div class="col-sm-10">
										<input class="form-control" id="token" type="text" placeholder="root" value="test" />
									</div>
								</div>
							</fieldset>
							<fieldset>
								<legend>数据库</legend>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="appid">Host</label>
									<div class="col-sm-10">
										<input class="form-control" id="appid" type="text" placeholder="root" value="http://7xrn9i.com1.z0.glb.clouddn.com/" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="aeskey">User</label>
									<div class="col-sm-10">
										<input class="form-control" id="aeskey" type="text" placeholder="root" value="CxotMa3cWZC4EhtfB4wHRG-UEBvzXjtwzPMV2OCB"/>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="appsecret">Password</label>
									<div class="col-sm-10">
										<input class="form-control" id="appsecret" type="text" placeholder="root" value="wpTkX2hUKlSH65I-Nn8-ABrGmWjoAlTyEZOoxODC" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="token">DataBaseName</label>
									<div class="col-sm-10">
										<input class="form-control" id="token" type="text" placeholder="root" value="mmlink" />
									</div>
								</div>
							</fieldset>
						</form>
					</dd>
					<dt>
                <a href="#accordion2" aria-expanded="false" aria-controls="accordion2" class="accordion-title accordionTitle js-accordionTrigger">坐席配置</a>
              </dt>
					<dd class="accordion-content accordionItem is-collapsed" id="accordion2" aria-hidden="true">
						<fieldset>
							<legend></legend>
							<div class="form-group">
								<label for="agent" class="col-sm-2 control-label">选择坐席数</label>
								<div class="col-sm-10">
									<select id="agent" class="form-control">
										<option>10</option>
										<option>20</option>
										<option>50</option>
										<option>100</option>
										<option>200</option>
									</select>
								</div>
							</div>
						</fieldset>
						<fieldset>
							<legend></legend>
							<div class="form-group">
								<label for="agent" class="col-sm-2 control-label">业务类型</label>
								<div class="col-sm-10">
									<input class="form-control" id="token" type="text" placeholder="请直接输入业务类型、用分号分隔" value="售前咨询;售后客服;问题反馈;投诉建议" />
								</div>
							</div>
						</fieldset>
					</dd>
			</div>
			<div class="mybutton" id="apply">
				应用
			</div>
		</div>
		<script src="res/install/install.js" type="text/javascript" charset="utf-8"></script>
		<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
		<script type="text/javascript">
			$(function() {
				$("#apply").on("click", function() {
					var appid = $("#appid").val();
					var aeskey = $("#aeskey").val();
					var appsecret = $("#appsecret").val();
					var token = $("#token").val();
					if (appid && aeskey && appsecret && token) {
						$.ajax({
							url:"/agent/create/"+$("#agent").val(),
							type:"get"
						})
						$.ajax({
							type: "post",
							data: JSON.stringify({
								"token": token,
								"appid": appid,
								"encodingAESKey": aeskey,
								"appsecret":appsecret
							}),
							url: "/agent/config",
							contentType: "application/json;charset=utf-8",
							success: function(res) {
								$.get("/start",function(){
									$(".container *").hide();
									var a=$('<div class="mybutton">配置已完成、开始使用</div>').appendTo($(".container"));
									a.click(function(){
										document.location.href="/login";
									})
								});
							},
							error: function() {
							}
						})
					} else {
						$("#tip").text("请完整填写配置信息");
					}
				})
			})
		</script>
	</body>

</html>